﻿using BussinessObject.ObjectTwo;
using Class_Entity.ObjectTwo;
using ProjectHK3.App_Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectHK3.Object_One
{
    public partial class CreateFeePolicy : System.Web.UI.Page
    {
        B_LoadDrop ld = new B_LoadDrop();
        B_Insert bi = new B_Insert();
        Delivery_free_polices df = new Delivery_free_polices();
        protected void Page_Load(object sender, EventArgs e)
        {
            load();
        }
        public void load()
        {
            DropDownList1.DataSource = ld.service();
            DropDownList1.DataTextField = "SERVICE_NAME";
            DropDownList1.DataValueField = "SERVICE_ID";
            DropDownList1.DataBind();
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            df.SERVICE_ID =int.Parse(DropDownList1.SelectedValue.ToString());
            df.DISTANCE_FROM = float.Parse(TextBox1.Text.ToString());
            df.DISTANCE_TO = float.Parse(TextBox2.Text.ToString());
            df.FEE_PER_KM = float.Parse(TextBox3.Text.ToString());
            df.WEIGHT_FROM = float.Parse(TextBox4.Text.ToString());
            df.WEIGHT_TO = float.Parse(TextBox5.Text.ToString());
            df.FEE_PER_KG = float.Parse(TextBox6.Text.ToString());
            if (bi.InsertFeePolicy(df) == false)
            {
                Alert.Show("Error!");
            }
            else
            {
                Alert.Show("Successful!");
                Response.Redirect("../Object One/FeePolicy.aspx");
            }
        }
    }
}